//
//  BQMineHelpController.m
//  BeeQuick
//
//  Created by student on 2017/7/12.
//  Copyright © 2017年 BecomeRich. All rights reserved.
//

#import "BQMineHelpController.h"
#import "BQMineProblemController.h"

@interface BQMineHelpController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation BQMineHelpController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"客服与帮助";
//    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self setupUI];
}

- (void)setupUI{
    UITableView *tableView = [[UITableView alloc]init];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.rowHeight = 50;
    tableView.tableFooterView = [UIView new];
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"BQMineHelpControllerCell"];
    [self.view addSubview:tableView];
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.leading.trailing.equalTo(self.view);
        make.height.offset(200);
    }];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BQMineHelpControllerCell" forIndexPath:indexPath];
    if (indexPath.row == 0) {
        cell.textLabel.text = @" 客服电话:400-8484-842";
    }else{
        cell.textLabel.text = @" 常见问题";
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return  10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return  0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 1) {
        BQMineProblemController *problemController = [[BQMineProblemController alloc]init];
        [self.navigationController pushViewController:problemController animated:NO];
    }else{
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil  message:@"400-8484-842" preferredStyle:UIAlertControllerStyleAlert];
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.backgroundColor = [UIColor blackColor];
        [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            [self dismissViewControllerAnimated:YES completion:nil];
        }]];
        [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
         [self dismissViewControllerAnimated:YES completion:nil];
        }]];
        [self presentViewController:alert animated:YES completion:nil];
    }
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
@end
